package cn.itcast.web.stat;

import cn.itcast.service.stat.StatService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {

 @Reference
 private StatService statService;

 /**
  * 进入统计页面
  * /stat/toCharts.do?chartsType=factory
  */
 @RequestMapping("/toCharts")
 public String toCharts(String chartsType) {
  return "stat/stat-"+chartsType;
 }

 /**
  * 通过ajax的请求，获取厂家的销量统计
  */
 @RequestMapping("/findFactoryData")
 public @ResponseBody List findFactoryData() {
  return statService.findFactoryData(getLoginCompanyId());
 }

 /**
  * 通过ajax的请求，获取产品的销量排行榜
  */
 @RequestMapping("/findSellData")
 public @ResponseBody
 List findSellData() {
  return statService.findSellData(getLoginCompanyId());
 }

 /**
  * 通过ajax的请求，获取系统访问压力图数据
  */
 @RequestMapping("/findOnlineData")
 public @ResponseBody
 List findOnlineData() {
  return statService.findOnlineData(getLoginCompanyId());
 }

 /**
  * 通过ajax的请求，获取单价排行数据
  */
 @RequestMapping("/findPriceData")
 public @ResponseBody
 List findPriceData() {
  return statService.findPriceData(getLoginCompanyId());
 }

 /**
  * 通过ajax的请求，获取ip登录次数排行数据
  */
 @RequestMapping("/findIpData")
 public @ResponseBody
 List findIpData() {
  return statService.findIpData(getLoginCompanyId());
 }
}
